var tit = getElementByClass("download_file_title");

if (tit) {
	if (tit.innerHTML.match(/\.mp4/i)) {
		var box = document.createElement("div");
		box.style.backgroundColor = "#000000";
		box.style.color = "#FFFFFF";
		box.style.width = "640px";
		box.style.height = "360px";
		box.style.position = "absolute";
		box.style.top = "0";
		box.style.left = "0";
		box.style.textAlign = "center";
		box.style.fontSize = "12px";
		box.style.fontFamily = "'Lucida Grande', Arial, Helvetica, sans-serif";
		box.style.zIndex = "10000";
		document.body.appendChild(box);
		var box2 = document.createElement("div");
		box2.id = "box2"
		box2.style.paddingTop = "160px";
		box.appendChild(box2);
		box2.innerHTML = "Cargando, por favor espera...";
		setTimeout("getLink()",3000);
	}
}

// Funciones
function getElementByClass(theClass) {
	var allHTMLTags=document.getElementsByTagName("*");
	for (i=0; i<allHTMLTags.length; i++) {
		if (allHTMLTags[i].className==theClass) {
			return allHTMLTags[i];
		}
	}
	return false;
}
function getLink() {
	var t = document.getElementById("download_visible_wrapper").childNodes;
	console.log(t[5].childNodes[1].childNodes[1].childNodes[0].childNodes[3].childNodes[1].childNodes);
	var d = t[5].childNodes[1].childNodes[1].childNodes[0].childNodes[3].childNodes[1];
	var divs = d.getElementsByTagName("div");
	var a;
	for(i=0;i<divs.length;i++) {
		if (divs[i].style.display == "block" && divs[i].style.position != "absolute") {
			a = divs[i].firstChild;
			break;
		}
	}
	alert(a.href);
	if (a.href != null && a.href != 'undefined') {
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).replace(/amp;/gi,'');
		
		//window.location = 'http://www.cuevana.tv/player/play2.php?megaurl='+a.href+'&count=20&mfire='+hashes;
	} else {
		setTimeout("getLink()",1000);
	}
}